#!/bin/bash
mkdir qingning
clear
cd qingning
echo -e "\033[31m 由于centOs的Python版本较低，所以需要升级Python，输入y进行升级 \033[0m"
echo "输入y升级安装"
echo "如果你已经安装，请输入n跳过"
read -p "请输入：" input
if [ $input == 'y' ]; then
    clear
    echo "卸载现有的Python"
    rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
    whereis python3 |xargs rm -frv
    echo "脚本开始安装Python3.8"
    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
    yum install -y gcc
    wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0a1.tgz
    tar -zxvf Python-3.8.0a1.tgz
    cd Python-3.8.0a1
    ./configure --prefix=/usr/local/python3
    make && make install
    ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
    echo "安装完成，请输入python3进行验证"

elif [ $input == 'n' ]; then
    clear
    echo -e "\033[32m 欢迎使用青柠Linux脚本，本脚本建议在centOs7.x版本运行 \033[0m"
    echo -e "\033[32m 声明：脚本不存在任何商业行为，完全免费使用 \033[0m"
    echo -e "\033[32m 并且已经开源，没有任何后门，绝对的安全 \033[0m"
    echo -e "\033[32m 官方博客：http://www.qingningz.cn/ \033[0m"
    echo -e "\033[37m 开源地址：https://gitee.com/zhuxiaohuaqn/Linux_shell \033[0m"
    read -p "如果你已经阅读完成，输入y开始使用脚本：" input
    if [ $input == 'y' ]; then
        cd qingning
        clear
        echo "欢迎使用青柠Linux脚本"
        echo "1.安装宝塔"
        echo "2.kangle工具箱"
        echo "3.一键安装网站"
        echo "4.服务器环境配置"
        echo "5.内网穿透"
        read -p "请选择：" input1
        #安装宝塔
        if [ $input1 == '1' ]; then
            clear
            wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/bt.sh -O bt.sh && sh bt.sh
        
        #安装kangle
        elif [ $input1 == '2' ]; then
            clear
            echo "1.kangle脚本合集"
            echo "2.kangle模板合集"
            echo "3.kangle自动备份至腾讯云对象存储"
            read -p "请选择：" jb
            if [ $jb == '1' ]; then
                wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/kangle.sh -O kangle.sh && sh kangle.sh
            elif [ $jb == '2' ]; then
                wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/kanglemoban.sh -O kanglemoban.sh && sh kanglemoban.sh

            elif [ $jb == '3' ]; then
                wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/bfkangle.sh -O bfkangle.sh && sh bfkangle.sh
            fi


        #安装网站
        elif [ $input1 == '3' ]; then
            clear
            wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/webinstall.sh -O webinstall.sh && sh webinstall.sh


        #服务器环境配置
        elif [ $input1 == '4' ]; then
            clear
            wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/linux_.sh -O linux_.sh && sh linux_.sh

        #内网穿透
        elif [ $input1 == '5' ]; then
            clear
            echo "两种不同的穿透工具，推荐第一种"
            echo "1.nps"
            echo "2.frp"
            read -p "请选择：" nw
            if [ $nw == '1' ]; then
                wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/nps.sh -O nps.sh && sh nps.sh
            elif [ $nw == '2' ]; then
                echo "1.安装服务端(带公网IP的服务器)"
                echo "2.安装本地端(要穿透的服务器)" 
                read -p "请选择：" frp
                if [ $frp == '1' ]; then
                    clear     
                    echo "开始安装内网穿透服务端"
                    wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/frp.sh -O frp.sh && sh frp.sh
                elif [ $frp == '2' ]; then
                    echo "开始安装内网穿透本地端"
                    wget https://gitee.com/zhuxiaohuaqn/Linux_shell/raw/master/frp.sh -O frp.sh && sh frp.sh
                fi
            fi
        fi
    fi
fi         
        